﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;

namespace XiaoCiLang
{
    class Program
    {
        static void Main(string[] args)
        {
            //定义数据库连接字符串
            string qmy = "server=.;database=XiaocilangOrdering;Integrated Security=true";
            //创建连接对象
            SqlConnection Conn = new SqlConnection(qmy);
            //打开数据库连接
            Conn.Open();
            //检测数据库连接是否打开
            if (Conn.State==System.Data.ConnectionState.Open)
            {
                Console.WriteLine("欢迎使用小次郎");
                Console.WriteLine("新用户注册");
                Console.WriteLine("用户昵称");
                string name = Console.ReadLine();
                Console.WriteLine("手机号");
                string tel= Console.ReadLine();
                Console.WriteLine("身份证号");
                string IDcard= Console.ReadLine();
                Console.WriteLine("地址");
                string address= Console.ReadLine();
                //Console.WriteLine("验证码");
                Console.WriteLine("密码");
                string pwd= Console.ReadLine();
                Console.WriteLine("二次确认密码");
                string pwd1 = Console.ReadLine();
                Console.WriteLine("支付密码（6位）");
                string pwd2 = Console.ReadLine();
                Console.WriteLine("完成注册");
                //创建插入的SQL语句
                string sql = string.Format("insert into User1 values('{0}','{1}','{2}','{3}','{4}')",name,tel,IDcard,address,pwd);
                //创建Command对象
                SqlCommand cmd = new SqlCommand(sql, Conn);
                //执行SQL语句
                if (cmd.ExecuteNonQuery()>0)
                {
                    Console.WriteLine("完成注册");
                }
                else
                {
                    Console.WriteLine("注册失败");
                }
            }
            //静态成员
            Way.Wayss.comName = "小次郎点餐";
            Way.Wayss.Show_S_Info();

            //非静态成员
            Way.Wayss Ta = new Way.Wayss();
            Ta.name = "小次郎";
            Ta.ShowInfo();
            //查询对象
            string qmy1 = "select *from User1";
            SqlCommand qmy2 = new SqlCommand(qmy1, Conn);
            SqlDataReader qmy3 = qmy2.ExecuteReader();
            Console.WriteLine("用户昵称\t手机号\t身份证号\t地址\t密码\n----------------------------------------------");
            while (qmy3.Read())
            {

                Console.WriteLine("{0}\t{1}\t{2}\t\t{3}\t\t{4}", qmy3[0], qmy3[1], qmy3[2], qmy3[3], qmy3[4]);
            }
            Conn.Close();

        }
    }
}
